/**
 * 
 */
package com.hanhai.zrb.api.biz.dao.mybatis;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

import com.hanhai.zrb.api.biz.dao.mybatis.base.BaseMapper;
import com.hanhai.zrb.model.message.MessageReceive;

/**
 * @author ricky
 *
 */
public interface MessageReceiveDao extends BaseMapper {
	
	
	@SelectKey(statement="select LAST_INSERT_ID()", keyProperty="id", keyColumn="id",before=false, resultType=long.class)
	@Insert("insert into message_receive(receiverUid,type,messageInfoId,createTime,`read`,status) values(#{receiverUid},#{type},#{messageInfoId},#{createTime},#{read},#{status})")
	void save(MessageReceive messageReceive);
	
	void batchSave(List<MessageReceive> list);
	
	List<MessageReceive> queryByReceiveUid(@Param("receiverUid") Long receiverUid,@Param("read")Integer read);
	
	List<MessageReceive> queryByReceiveUidForMaxId(@Param("receiverUid") Long receiverUid,@Param("read")Integer read,@Param("maxId") Long maxId,@Param("limit") Integer limit);
	
	@Update("update message_receive set `read` = 1 where id=#{id} and receiverUid=#{receiverUid} and `read` = 0")
	int updateRead(@Param("receiverUid") Long receiverUid,@Param("id")Long id);
	
	int updateReadBatch(@Param("receiverUid") Long receiverUid,@Param("idList") List<Long> idList);
	
}
